﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using HighDivePrinter.Model;
using HighDivePrinter.Properties;


using System.Xml;
using System.Xml.Serialization;
using System.ComponentModel;

namespace HighDivePrinter.Model
{
    /// <summary>
    ///Data Class that holds data for a judge.
    /// </summary>
    [Serializable()]
    
    public class Judge : DiveScore, IComparable<Judge>
    {
        

        #region Properties

        
        private string _IdString;
        private string _IpAdress;
        private int _JudgeNumber;
        private int? _DbId;
       // private JudgeStatus _Status;

        /// <summary>
        ///IdString used for identification when a score is updated by the judge.
        /// </summary>
        public  string IdString 
        {
            get
            {
                return _IdString;
            }
            set
            {
                _IdString = value;
                if (this.PropertyChanged != null)
                    this.PropertyChanged(this, new PropertyChangedEventArgs("IdString"));
            }
        }
        public  string IpAdress 
        {
            get
            {
                return _IpAdress;
            }
            set
            {
                _IpAdress = value;
                if (this.PropertyChanged != null)
                    this.PropertyChanged(this, new PropertyChangedEventArgs("IpAddress"));
            }
        }
        public int JudgeNumber
        {
            get
            {
                return _JudgeNumber;
            }
            set
            {
                _JudgeNumber = value;
                if (this.PropertyChanged != null)
                    this.PropertyChanged(this, new PropertyChangedEventArgs("JudgeNumber"));
            }
        }
        public int? DbId 
        {
            get
            {
                return _DbId;
            }
            set
            {
                _DbId = value;
                if (this.PropertyChanged != null)
                    this.PropertyChanged(this, new PropertyChangedEventArgs("DbId"));
            }
        }
     /*   public JudgeStatus Status 
        {
            get
            {
                return _Status;
            }
            set
            {
                _Status = value;
                if (this.PropertyChanged != null)
                    this.PropertyChanged(this, new PropertyChangedEventArgs("Status"));
            }
        }
        */
        #endregion

        #region Constructors

        public Judge()
        {
            IdString = null;
            IpAdress = null;
            //PersonDbId = null;
            DbId = null;
            JudgeNumber = 0;
           // Status = new JudgeStatus();
           // Status.SetTo(JudgeStatus.Status.Na);
        }

        #endregion

        public bool Equals(Judge other)
        {
            return IdString == other.IdString;
        }

      /*  public override string ToString()
        {
            return IdNumber + " " + FirstName + " " + LastName;
        }*/

        #region IComparable Members

        /// <summary>
        /// Method that defines comparison of two Divers.
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public int CompareTo(Judge obj)
        {
            int c = this._DbId.Value.CompareTo(obj._DbId.Value);
            if (c == 0)
                return this._IdString.CompareTo(obj._IdString);
            else
                return c;
        }

        #endregion

        #region INotifyPropertyChanged Members
        /// <summary>
        /// Event declaration.
        /// </summary>
        public event PropertyChangedEventHandler PropertyChanged;

        #endregion
    }
}
